package com.mayuhao.homework;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.mayuhao.homework.chapter3.homework3四1_加法计算.AdditionActivity;
import com.mayuhao.homework.chapter3.homework3四2_自定义对话框.CustomDialogActivity;
import com.mayuhao.homework.chapter5.homework5四2_用户登录_数据保存.SaveQQActivity;
import com.mayuhao.homework.chapter5.homework5四3_购物车_CRUD.ShoppingMallActivity;


public class MainActivity extends AppCompatActivity {
    private Button btnAddition;
    private Button btnCustomDialog;
    private Button btnUserLogin;
    private Button btnMoney;
    private Button btnShoppingMallCrud;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnAddition = findViewById(R.id.btn_addition);
        btnCustomDialog = findViewById(R.id.btn_custom_dialog);
        btnUserLogin = findViewById(R.id.btn_user_login);
        btnMoney = findViewById(R.id.btn_money);
        btnShoppingMallCrud = findViewById(R.id.btn_shopping_mall_crud);
        SetListeners();


    }


    public void SetListeners() {
        OnClick onClick = new OnClick();
        btnAddition.setOnClickListener(onClick);
        btnCustomDialog.setOnClickListener(onClick);
        btnUserLogin.setOnClickListener(onClick);
        btnMoney.setOnClickListener(onClick);
        btnShoppingMallCrud.setOnClickListener(onClick);
    }

    private class OnClick implements View.OnClickListener {

        @Override
        public void onClick(View view) {
            Intent intent = null;
            switch (view.getId()) {
                case R.id.btn_addition:
                    intent = new Intent(MainActivity.this, AdditionActivity.class);
                    break;
                case R.id.btn_custom_dialog:
                    intent = new Intent(MainActivity.this, CustomDialogActivity.class);
                    break;
                case R.id.btn_user_login:
                    intent = new Intent(MainActivity.this, SaveQQActivity.class);
                    break;
                case R.id.btn_money:
                Toast.makeText(MainActivity.this, "这是逻辑代码~ 贵公子在项目中查看哦~", Toast.LENGTH_LONG).show();
                    return;
                case R.id.btn_shopping_mall_crud:
                    intent = new Intent(MainActivity.this, ShoppingMallActivity.class);
                    break;
            }
            startActivity(intent);
        }
    }


}